package net.maku.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import net.maku.bean.query.WebPayRecordQuery;
import net.maku.bean.vo.WebPayRecordVO;
import net.maku.convert.WebPayRecordConvert;
import net.maku.entity.WebPayRecordEntity;
import net.maku.mapper.WebPayRecordMapper;
import net.maku.utils.PageResult;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 支付信息表
 *
 * @author 阿沐 babamu@126.com
 * @since 1.0.0 2024-09-02
 */
@Service
@AllArgsConstructor
public class WebPayRecordServiceImpl extends BaseServiceImpl<WebPayRecordMapper, WebPayRecordEntity>  {

	/*
    public PageResult<WebPayRecordVO> page(WebPayRecordQuery query) {
        IPage<WebPayRecordEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));

        return new PageResult<>(WebPayRecordConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
    }*/

    private LambdaQueryWrapper<WebPayRecordEntity> getWrapper(WebPayRecordQuery query){
        LambdaQueryWrapper<WebPayRecordEntity> wrapper = Wrappers.lambdaQuery();
        return wrapper;
    }

    public void save(WebPayRecordVO vo) {
        WebPayRecordEntity entity = WebPayRecordConvert.INSTANCE.convert(vo);

        baseMapper.insert(entity);
    }

    public void update(WebPayRecordVO vo) {
        WebPayRecordEntity entity = WebPayRecordConvert.INSTANCE.convert(vo);

        updateById(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    public void delete(List<Long> idList) {
        removeByIds(idList);
    }

}